package com.ftg.learn.chapter11.xml;

import com.ftg.learn.chapter04.isa.Dog;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.List;

/**
 * @author 布衣
 */
public class SpringContainer {

    public static void main(String[] args) {
//        spring 用于管理类的生命周期以及类与类之间的关系

        //1 所有的实际开发类，全要仍给spring实例化.
        //2 spring ioc 的功能，spring是如何完成类的实例化的？
        //2.1 完成类的注册
        //2.2 int String double char long List  Map
        BeanFactory beanFactory = new ClassPathXmlApplicationContext("base/spring.xml");
        PetStore bean = beanFactory.getBean(PetStore.class);

        System.out.println(bean.getName());

        System.out.println(bean.getDog().size());
        List<Dog> dog = bean.getDog();
        for (Dog dog1 : dog) {
            System.out.println(dog1.getName());
        }
    }

}
